package cn.itcast.controller.state;

import cn.itcast.base.BaseController;
import cn.itcast.service.stat.StatService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "/stat")
public class StatController extends BaseController {

    @Reference
    private StatService statService;
    @RequestMapping(value = "/toCharts")
    public String toCharts(String chartsType){ //chartsType是用来走指定页面的

        return "stat/stat-"+chartsType;
    }

    @RequestMapping(value = "/getFactoryData",name = "厂商货物的销售总金额")
    @ResponseBody
    public List getFactoryData() {
        List<Map> factoryData = statService.getFactoryData(companyId);
        System.out.println(factoryData);
        return factoryData;
    }

    @RequestMapping(value = "/getSellData",name = "货物销售总金额前15名")
    @ResponseBody
    public List getSellData() {
        List<Map> sellData = statService.getSellData(companyId);
        System.out.println(sellData);
        return sellData;
    }

    @RequestMapping(value = "/getonlineData",name = "系统访问压力数据")
    @ResponseBody
    public List getonlineData() {
        List<Map> maps = statService.getonlineData(companyId);
        System.out.println("maps = " + maps);
        return maps;
    }
    @RequestMapping(value = "/getIpDate",name = "Ip前十名")
    @ResponseBody
    public List getIpData(){

        return statService.getIpData(companyId);
    }

    @RequestMapping(value = "/getSellDataTen",name = "市场前十名")
    @ResponseBody
    public List getSellDataTen(){

        return statService.getSellDataTen();
    }
}
